import React, { useState } from "react";
import ErrorBoundary from "./ErrorBoundary";
import LevelOne from "./LevelOne";

export default function MyFuncComp() {
  const [info, setInfo] = useState({
    msg: {
      value: <span>这是一条正常的消息</span>,
    },
  });

  function handleClick() {
    // 点击模拟，接收到了一个没有 value 字段的对象
    setInfo({
      msg: "这是第二条消息",
    });
  }

  return (
    <ErrorBoundary>
      <button onClick={handleClick}>模拟触发一个错误</button>
      <LevelOne msgObj={info} />
    </ErrorBoundary>
  );
}
